package com.drinking.consumerwithhystrix.hystrix;

import com.netflix.hystrix.HystrixCommand;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.web.client.RestTemplate;

public class MyHystrixCommand extends HystrixCommand {

    private RestTemplate restTemplate;
    private String url;

    public MyHystrixCommand(Setter setter, RestTemplate restTemplate, String url) {
        super(setter);
        this.restTemplate=restTemplate;
        this.url=url;
    }

    @Override
    protected Object run() throws Exception {
        return restTemplate.getForObject("http://SPRINGCLOUD-PROVIDER/test03",String.class);
    }

    @Override
    protected String getFallback() {
        return "自定义熔断器类熔断处理，异常:"+executionResult.getExecutionException();
    }


}
